package com.zk.ppa.controller;

import com.zk.ppa.commom.result.Result;
import com.zk.ppa.dao.po.EducationFunding;
import com.zk.ppa.dao.po.Train;
import com.zk.ppa.service.EducationFundingService;
import com.zk.ppa.service.TrainService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author fengq
 */
@RestController
@Api(tags = "教育措施相关接口")
@RequestMapping("/education")
@CrossOrigin
public class EducationFundingController {
    @Autowired
    private EducationFundingService educationFundingService;

    @ApiOperation(value = "添加基本措施")
    @PostMapping
    public Result save(@RequestBody EducationFunding educationFunding){
        return educationFundingService.saveEducation(educationFunding)?Result.SUCCESS().setData(educationFunding):Result.FAIL("添加失败");
    }

    @ApiOperation(value = "修改基本措施")
    @PutMapping
    public Result updateById(@RequestBody EducationFunding educationFunding){
        return educationFundingService.updateEducationById(educationFunding)?Result.SUCCESS().setData(educationFunding):Result.FAIL("修改失败");
    }

    @ApiOperation(value = "删除基本措施")
    @DeleteMapping("/{id}")
    public Result deleteById(@PathVariable(value = "id") @ApiParam(value = "基本表id") Long id){
        return educationFundingService.deleteEducationById(id)?Result.SUCCESS().setMessage("删除成功"):Result.FAIL("修改失败");
    }

    @ApiOperation(value = "批量删除基本措施")
    @DeleteMapping("/{ids}")
    public Result deleteById(@PathVariable(value = "ids") @ApiParam(value = "基本表ids") List<Long> ids){
        return educationFundingService.deleteBatchEducationByIds(ids)?Result.SUCCESS().setMessage("删除成功"):Result.FAIL("修改失败");
    }
}
